/*
 Xern Entity Relocation Network
 Copyright (C) 2010-2011 Ronie Salgado <roniesalg@gmail.com>

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
*/

#ifndef XERN_REGION_MESH_HPP
#define XERN_REGION_MESH_HPP

#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp>
#include "Vector.hpp"
#include "AABox.hpp"

#define RMVF_POSITION 	1
#define RMVF_NORMAL 	(1<<1)
#define RMVF_TEXCOORD 	(1<<2)
#define RMVF_LIGHTCOORD (1<<3)
#define RMVF_TANGENT 	(1<<4)
#define RMVF_BITANGENT 	(1<<5)
#define RMVF_MAPXERN (RMVF_POSITION|RMVF_NORMAL|RMVF_TEXCOORD|\
					  RMVF_LIGHTCOORD|RMVF_TANGENT|RMVF_BITANGENT)

namespace Xern
{
	struct RegionSubMesh
	{
		std::string materialName;
		unsigned int indexSize;
		unsigned int numTriangles;
		boost::shared_array<unsigned char> triangles;
	};

	struct IGeometry;
	struct RegionMesh
	{
		typedef std::vector<boost::shared_ptr<RegionSubMesh> > SubMeshes;
		SubMeshes subMeshes;

		size_t vertexSize;
		unsigned int vertexFlags;
		unsigned int numVertices;
		AABox boundingBox;
		boost::shared_array<unsigned char> vertexBuffer;
		std::string name;
		boost::shared_ptr<IGeometry> geometry;
	};

	// Region vertex layout
	//struct Vertex
	//{
	//  typedef float[3] Vector3;
	//  typedef float[2] Vector2;
	//	Vector3 position;
	//	Vector3 normal;
	//	Vector2 texCoord;
	//	Vector2 lightCoord;
	//	Vector3 tangent;
	//	Vector3 bitangent;
	//};
};
#endif //XERN_REGION_MESH_HPP
